package com.efast.cafe.portal.service.query.impl;

import java.util.List;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.efast.cafe.portal.bean.query.FieldTypeBean;
import com.efast.cafe.portal.bean.query.FieldTypeOpBean;
import com.efast.cafe.portal.dao.query.FieldTypeDao;
import com.efast.cafe.portal.entity.query.FieldOp;
import com.efast.cafe.portal.entity.query.FieldType;
import com.efast.cafe.portal.service.query.IFieldTypeService;
@Service
@Transactional
public class FieldTypeServiceImpl implements IFieldTypeService {

	@Autowired
	private FieldTypeDao fieldTypeDao;
	@Override
	public int addFieldType(FieldType fieldType) {
		// TODO Auto-generated method stub
		fieldType.setIsDelete(0);
		return fieldTypeDao.addFieldType(fieldType);
	}

	@Override
	public int deleteFieldType(Integer id) {
		// TODO Auto-generated method stub
		if(fieldTypeDao.selectOpCountByFieldTypeId(id)>0){
			return 0;
		}
		return fieldTypeDao.deleteFieldType(id);
	}

	@Override
	public int addFieldOp(FieldOp fieldOp) {
		// TODO Auto-generated method stub
		fieldOp.setIsDelete(0);
		return fieldTypeDao.addFieldOp(fieldOp);
	}

	@Override
	public int deleteFieldOp(Integer id) {
		// TODO Auto-generated method stub
		return fieldTypeDao.deleteFieldOp(id);
	}

	@Override
	public FieldTypeBean selectFieldTypeById(FieldTypeBean fieldTypeBean) {
		// TODO Auto-generated method stub
		List<?> resultList=fieldTypeDao.selectFieldTypeById(fieldTypeBean.getId());
		fieldTypeBean.setResultList(resultList);
		fieldTypeBean.setTotalRows(resultList.size());
		return fieldTypeBean;
	}

	@Override
	public FieldTypeOpBean selectOpbyFieldTypeId(FieldTypeOpBean fieldTypeOpBean) {
		// TODO Auto-generated method stub
		List<?> resultList=fieldTypeDao.selectOpbyFieldTypeId(fieldTypeOpBean.getFieldTypeId());
		fieldTypeOpBean.setResultList(resultList);
		fieldTypeOpBean.setTotalRows(resultList.size());
		return fieldTypeOpBean;
	}

}
